package com.soft.javase.day15.reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/5/27
 */
public class ReflectDemo2 {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);

        Class<List> clazz = List.class;
        Method method = clazz.getDeclaredMethod("add", Object.class);
        Object flag = method.invoke(list, "abc");
        System.out.println("flag=" + flag);

        System.out.println(list);
    }
}
